/**
 * Created by Administrator on 2017/3/29 0029.
 */
var Page0={
    create:function () {
        var page={};
        page.ui=new PIXI.DisplayObjectContainer();

        var arr_texture=[];
        for(var i=0;i<43;i++)
        {
            if(i<10)
            {
                var texture = resource['assets/images/s2/S2__0000'+i.toString()+'.jpg'].texture;
            }
            else if(i<100)
            {
                var texture = resource['assets/images/s2/S2__000'+i.toString()+'.jpg'].texture;
            }
            arr_texture.push(texture);
        }

        var sp_bgBlur=Easy.CreateSprite('assets/images/bgBlur.png',-74,-86,0,0,0)
        page.ui.addChild(sp_bgBlur);

        var mc=new PIXI.extras.AnimatedSprite(arr_texture);
        mc.alpha=0;
        mc.animationSpeed=0.25;
        mc.loop=false;
        mc.x=0;
        mc.y=0;
        page.ui.addChild(mc);

        var sp_bg=new PIXI.Sprite(resource['assets/images/p0_bg.png'].texture);
        sp_bg.anchor.set(0.0);
        sp_bg.x = 0;
        sp_bg.y = 545;
        page.ui.addChild(sp_bg);

        var t0=new PIXI.Sprite(resource['assets/images/p0_t0.png'].texture);
        t0.anchor.set(0.5);
        t0.x = 357;
        t0.y =90;
        page.ui.addChild(t0);

        var t1=new PIXI.Sprite(resource['assets/images/p0_t1.png'].texture);
        t1.anchor.set(0.5);
        t1.x = 380;
        t1.y = 243;
        page.ui.addChild(t1);

        var t2=new PIXI.Sprite(resource['assets/images/p0_t2.png'].texture);
        t2.anchor.set(0.5);
        t2.x = 382;
        t2.y = 346;
        page.ui.addChild(t2);

        var t3=new PIXI.Sprite(resource['assets/images/p0_t3.png'].texture);
        t3.anchor.set(0.5);
        t3.x = 374;
        t3.y = 443;
        page.ui.addChild(t3);

        var sp_i0=new PIXI.Sprite(resource['assets/images/p0_i0.png'].texture);
        sp_i0.anchor.set(0.5);
        sp_i0.x=371;
        sp_i0.y=687+55;
        page.ui.addChild(sp_i0);

        var sp_i1=new PIXI.Sprite(resource['assets/images/p0_i1.png'].texture);
        sp_i1.anchor.set(0.5);
        sp_i1.x=371;
        sp_i1.y=767+60;
        page.ui.addChild(sp_i1);

        var sp_i2=new PIXI.Sprite(resource['assets/images/p0_i2.png'].texture);
        sp_i2.anchor.set(0.5);
        sp_i2.x=371;
        sp_i2.y=910+80;
        page.ui.addChild(sp_i2);
        sp_i2.interactive=true;
        sp_i2.on('pointerdown',downHandler);

        var sp_i3=new PIXI.Sprite(resource['assets/images/p0_i3.png'].texture);
        sp_i3.anchor.set(0.5);
        sp_i3.x=371;
        sp_i3.y=1015;
        // page.ui.addChild(sp_i3);

        var style={
            fontSize: 32,
            textWidth:1000,
            fill: ['#cccccc', '#cccccc'], // gradient
            dropShadowColor: '#000000',
            wordWrapWidth: 2040
        }
        //var text_name = new PixiTextInput("Name",style);
        // page.ui.addChild(text_name);
        //text_name.width=300;
        //text_name.x=200;
        //text_name.y=670;
        //text_name.interactive=true;
        //
        //var text_tel = new PixiTextInput("Telephone",style);
        // page.ui.addChild(text_tel);
        //text_tel.width=300;
        //text_tel.x=200;
        //text_tel.y=745;

        page.In=function () {

            TweenMax.to(sp_bgBlur,1.5,{delay:0.0,alpha:1,ease:Cubic.easeInOut});

            sp_bg.y=1136;
            sp_bg.alpha=0;
            TweenMax.to(sp_bg,1,{delay:1.5,y:545,alpha:1,ease:Cubic.easeInOut,onComplete:function () {
                // page.ui.addChildAt(mc,0);
                mc.alpha=1;
            }});
            setTimeout(function () {
                mc.gotoAndPlay(1);
            },2500);

            // mc.alpha=0.5;
            // TweenMax.to(mc,1,{delay:0.5,y:0,alpha:1,ease:Cubic.easeOut,onComplete:function () {
            //
            // }});


            // t0.y=90+70;
            // t0.alpha=0;
            // TweenMax.to(t0,1,{delay:1.5+0.2,y:90,alpha:1,ease:Back.easeOut});
            // t1.y=243+70;
            // t1.alpha=0;
            // TweenMax.to(t1,1,{delay:1.5+0.4,y:243,alpha:1,ease:Back.easeOut});
            // t2.y=346+70;
            // t2.alpha=0;
            // TweenMax.to(t2,1,{delay:1.5+0.6,y:346,alpha:1,ease:Back.easeOut});
            // t3.y=443+70;
            // t3.alpha=0;
            // TweenMax.to(t3,1,{delay:1.5+0.8,y:443,alpha:1,ease:Back.easeOut});
            t0.alpha=0;
            t1.alpha=0;
            t2.alpha=0;
            t3.alpha=0;

            sp_i0.scale.x=sp_i0.scale.y=0;
            TweenMax.to(sp_i0.scale,1,{delay:1.5+1.0,x:1,y:1,alpha:1,ease:Back.easeOut});
            sp_i1.scale.x=sp_i1.scale.y=0;
            TweenMax.to(sp_i1.scale,1,{delay:1.5+1.2,x:1,y:1,alpha:1,ease:Back.easeOut});
            sp_i2.scale.x=sp_i2.scale.y=0;
            TweenMax.to(sp_i2.scale,1,{delay:1.5+1.4,x:1,y:1,alpha:1,ease:Back.easeOut});
            sp_i3.scale.x=sp_i3.scale.y=0;
            TweenMax.to(sp_i3.scale,1,{delay:1.5+1.6,x:1,y:1,alpha:1,ease:Back.easeOut});


             setTimeout(function () {
                 document.getElementById('text_name').style.zIndex=99;
                 document.getElementById('text_tel').style.zIndex=99;
                 document.getElementById('text_name').style.display='';
                 document.getElementById('text_tel').style.display='';
                 document.getElementById('text_name').addEventListener('mousedown',mouseHandler);
                 document.getElementById('text_name').addEventListener('touchstart',mouseHandler);
                 document.getElementById('text_tel').addEventListener('mousedown',mouseHandler);
                 document.getElementById('text_tel').addEventListener('touchstart',mouseHandler);
             },3100)
            // text_name.alpha=0;
            // text_tel.alpha=0;
            document.getElementById('text_name').style.opacity=0;
            document.getElementById('text_name').style.opacity=0;
            TweenMax.to(document.getElementById('text_name').style,1,{delay:1.5+1.6,opacity:1,ease:Cubic.easeOut});
            TweenMax.to(document.getElementById('text_tel').style,1,{delay:1.5+1.6,opacity:1,ease:Cubic.easeOut});
            // TweenMax.to(text_tel,1,{delay:1.8,alpha:1,ease:Cubic.easeOut});

        }
        // function fOutHandler(e)
        // {
        //     console.log('out');
        //     textName= e.currentTarget.value;
        // }
        function mouseHandler(e)
        {
            console.log(e.currentTarget.id=='text_name',e.currentTarget.value=='Name');
            if(e.currentTarget.id=='text_name'&& e.currentTarget.value=='Name')
            {
                e.currentTarget.value='';

            }
            else if(e.currentTarget.id=='text_tel'&&e.currentTarget.value=='Tele')
            {
                e.currentTarget.value='';
            }
        }
        //var bool+
        function downHandler(e)
        {
            sp_i2.interactive=false;
            textName=document.getElementById('text_name').value;
            document.getElementById('text_name').style.zIndex=0;
            document.getElementById('text_tel').style.zIndex=0;
            e.currentTarget.scale.x=0.99;
            e.currentTarget.scale.y=0.99;
            var evt=new CustomEvent('Game_PageIn',{'detail':'1'});
            document.dispatchEvent(evt);
        }

        return page;
    }
}